package util

import "strings"

func Flags(args []string) []string {
	options := make([]string, 0)
	for _, arg := range args {
		if strings.HasPrefix(arg, "--tfwrapper-") {
			options = append(options, arg)
		}
	}
	return options
}

func Args(args []string) []string {
	arguments := make([]string, 0)
	for _, arg := range args {
		if !strings.HasPrefix(arg, "--tfwrapper-") {
			arguments = append(arguments, arg)
		}
	}
	return arguments
}

func SetSlice(args []string) []string {
	if len(args) <= 1 {
		return args
	}
	newArgs := make([]string, 0)
	for _, arg := range args {
		if !Contain(newArgs, arg) {
			newArgs = append(newArgs, arg)
		}
	}
	return newArgs
}

func ToEnvKey(name string) string {
	return strings.ToUpper(strings.ReplaceAll(name, "-", "_"))
}
